#ifndef CS270_CONNECTFOUR
#define CS270_CONNECTFOUR
#include "gameboard.h"

namespace CS270Game {
const int CFBOARDSIZE_X = 7;
const int CFBOARDSIZE_Y = 6;

class ConnectFour {
 public:
  //The fundamental board token - each space can either be empty or 
  // occupied by a token from the red or black player.
  enum CFToken {
    EMPTY,
    RED,
    BLACK
  };

  //Basic constructor
  ConnectFour() : board(), currentPlayer(RED) {};

  //Play the game for two (human) players.  Returns the 
  //  player that won the game
  CFToken playgame(); 

  //Take turn for the current player - calls private takeTurn function
  void takeTurn() {
    takeTurn(currentPlayer);
    if (currentPlayer == RED) {
      currentPlayer = BLACK;
    } else {
      currentPlayer = RED;
    }
  }

  class CFBoard : public GameBoard<CFToken> {
    //Constructor initialized the board to be of the specified size, and 
    // filled with EMPTY tokens.
   public:
    CFBoard() : GameBoard(CFBOARDSIZE_Y, CFBOARDSIZE_X, EMPTY) { };
    //A function to check whether the board is full, for a draw
    bool isFull();  
    // Returns whether or not the move is valid (column is in bounds and there is 
    // space to insert a token.)  
    // If the move is valid, inserts the token at the designated column.
    bool makeMove(int col, CFToken player); 

    //Print the board to console
    void printBoard();

    //Returns the winner of the game as one of the CFToken enum values.
    //A return value of 0/EMPTY indicates that there is no current winner.
    virtual int isWin();
  };

 private: 
  //Take one turn for the given player - private to ensure proper 
  //  player switching
  void takeTurn(CFToken player);

  //The board for the game
  CFBoard board;
  //The current player's turn
  CFToken currentPlayer;
};

}
#endif // CS270_2016FA_CONNECTFOUR
